// 引入公共头文件；
#include "common.h"
// 引入学生头文件；
#include "student.h"
// 元素类型定义；
typedef Student ElementType;
// 引入顺序线性表的头文件；
#include "sequencelist.h"

int main()
{
	SequenceList list;
	// 初始化线性表，并判断是否成功；
	if (InitList(&list) != 1)
	{	// 若失败；
		// 直接退出；
		exit(1);
	}

	ListAppend(&list, InitStudent(1, "张无忌", 23, 'M'));
	ListAppend(&list, InitStudent(3, "赵敏", 18, 'F'));
	ListAppend(&list, InitStudent(2, "郭靖", 45, 'M'));
	ListAppend(&list, InitStudent(5, "黄蓉", 41, 'F'));
	ListAppend(&list, InitStudent(4, "杨过", 33, 'M'));

	printf("length = %d\n", list.length);
	ListTraverse(&list, OutputStudent);
	ListDelete(&list, 2);
	printf("length = %d\n", list.length);
	ListTraverse(&list, OutputStudent);
	Student stu = InitStudent(5, "黄蓉", 41, 'F');
	printf("locate = %d\n", LocateElem(&list, stu, EqualsStudent));

	/*
	 ListAppend(&list, 71);
	 ListAppend(&list, 23);
	 ListAppend(&list, 36);
	 ListAppend(&list, 85);
	 ListAppend(&list, 11);
	 printf("length = %d\n", list.length);
	 ListTraverse(&list, OutputInt);
	 ListDelete(&list, 2);
	 printf("length = %d\n", list.length);
	 ListTraverse(&list, OutputInt);
	 printf("locate = %d\n", LocateElem(&list, 71, EqualsInt));
	 */

	return 0;
}
